const Redis = require('redis');

const redisClient = Redis.createClient({
  url: process.env.REDIS_URL || 'redis://localhost:6379'
});

redisClient.connect().catch(console.error);

redisClient.on('error', (err) => {
  console.error('Redis连接错误:', err);
});

redisClient.on('connect', () => {
  console.log('Redis连接成功');
});

redisClient.on('ready', () => {
  console.log('Redis准备就绪');
});

redisClient.on('end', () => {
  console.log('Redis连接断开');
});

module.exports = redisClient; 